﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Wicture.DbRESTFul.SQL;
using Wicture.QPZS.EPC.API.Domain.Entities;

namespace Wicture.QPZS.EPC.API.Repository
{
    public class ServiceRepository : DbRESTFulRepository, IServiceRepository
    {
        public void AddApiConsumed(int packageApiId, int cost)
        {
            base.Invoke("AddApiConsumed", new { packageApiId, cost });
        }

        public void AddCostLog(int accountId, int packageId, string apiName, string request, decimal cost)
        {
            base.Invoke("AddCostLog", new { accountId, packageId, apiName, request, cost });
        }

        public void AddPackageConsumed(int packageId, int cost)
        {
            base.Invoke("AddPackageConsumed", new { packageId, cost });
        }

        public void CostBalance(int id, decimal cost)
        {
            base.Invoke("CostBalance", new { id, cost });
        }

        public ServiceAccountEntity GetAccount(int id)
        {
            return base.Invoke<ServiceAccountEntity>("GetAccount", new { id });
        }

        public AccountPackageEntity GetAccountPackage(int accountId)
        {
            return base.Invoke<AccountPackageEntity>("GetAccountPackage", new { accountId });
        }

        public List<AccountPackageApiBrandEntity> GetAccountPackageApiBrands(int packageApiId)
        {
            return base.Invoke<AccountPackageApiBrandEntity>("List_api_service_package_api_brand", new { packageApiId }) as List<AccountPackageApiBrandEntity>;
        }

        public AccountPackageApiEntity GetAccountPackageApis(int packageId, int definitionId)
        {
            return base.Invoke<AccountPackageApiEntity>("GetAccountPackageApis", new { packageId, definitionId });
        }

        public ServiceDefinitionEntity GetServiceDefinition(string name)
        {
            return base.Invoke<ServiceDefinitionEntity>("GetServiceDefinition", new { name });
        }

        public ServicePackageEntity GetServicePackage(int packageId)
        {
            return base.Invoke<ServicePackageEntity>("GetServicePackage", new { packageId });
        }
    }
}
